﻿using SimStatus.Core;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Forms;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace SimStatus.UI
{
    /// <summary>
    /// MainBoard.xaml 的交互逻辑
    /// </summary>
    public partial class MainBoard : System.Windows.Controls.UserControl, IContent
    {
        public IMainPage main { get; set; }

        private  Timer timer1 = new Timer();
        public MainBoard()
        {
            InitializeComponent();
            this.Loaded += MainBoard_Loaded;
        }

        void MainBoard_Loaded(object sender, RoutedEventArgs e)
        {
            timer1.Enabled = true;
            timer1.Interval = 5000;
            timer1.Tick += timer1_Tick; 
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            this.blk_CGMM.Text = main.ExcuteAtCommang("at+cgmm?");
            Jpp.DoEvent();
            this.blk_COPS.Text = main.GetCops();
            Jpp.DoEvent();
            this.blk_COS.Text = main.GetCSQ();
            Jpp.DoEvent();
        }

        private void Open_Click(object sender, RoutedEventArgs e)
        {
            this.Open.IsEnabled = false;
            Jpp.DoEvent();
            if (main.IsDial)
            {
                main.UnDial();
            }
            else
            {
                main.Dial();
            }
            this.Open.IsEnabled = true;
            Jpp.DoEvent();
        }

    }
}
